import svgCaptcha from "svg-captcha";
import SysParamsSettingModel from "../../dao/model/system/SysParamsSettingModel";

export class CaptchaService {
  /**
   * 通过id获取数据
   */
  public static async getCaptchaImg() {
    const captcha = svgCaptcha.create({
      ignoreChars: "0o1ilIO",
      noise: 2,
      color: true,
      height: 40,
    });

    const enableCaptcha = await SysParamsSettingModel.findOne({
      where: {
        paramsCode: "enable_captcha",
      },
    });

    return { ...captcha, enableCaptcha: enableCaptcha.dataValues.paramsValue };
  }
}
